var vue = new Vue({
    el: ".container",
    data: {
        addressList: [],
        limitNum: 3,
        currentAddressIndex:0,
        shippingMethod:1,
        delFlag:false,
        currentDelIndex:null

    },
    filters: {},
    mounted: function () {
        this.$nextTick(
            () => this.cartView()
        )
    },
    methods: {
        cartView: function () {
            var _this = this;
            axios.get('data/address.json')
                .then((res) => {
                    _this.addressList = res.data.result;
                    // _this.totalMoney = res.data.result.totalMoney;
                    // console.log(res);
                    // console.log(res.data.result);
                })
                .catch((err) => {
                    console.log(err);
                });

        },
        setDefault:function (addressId) {
            this.addressList.forEach((v,i)=>{
                if (addressId==v.addressId){
                    v.isDefault = true;
                }else {
                    v.isDefault = false;
                }
            })
        },
        delconfig:function (index) {
            this.currentDelIndex = index;
            this.delFlag = true;
        },
        delProduct:function () {
            this.addressList.splice(this.currentDelIndex, 1);
            this.delFlag = false;

        }

    },
    computed: {
        filterAddress: function () {
            return this.addressList.slice(0, this.limitNum);
        }
    }

});

